import java.lang.invoke.SwitchPoint;
import java.lang.reflect.Array;
import java.util.Scanner;

import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT;

public class BMS {
	static String userinfo[][]=new String[100][4];
	static String BookInfo[][]=new String[100][5];
	static String PressInfo[][]=new String[100][3];
	static Scanner arr =new Scanner(System.in);
	
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
//		System.out.println("欢迎来到闽大图书管理系统！");
//		System.out.println("1.登录 2.注册");
//		Scanner sc =new Scanner(System.in);
//		int a= sc.nextInt();
//		
//			switch(a) {
//			case 1:
//				enter();
//			break;	
//			case 2:
//					register();
//					head();
//					break;
//				}
		head();
			}
	private static void head() {
		System.out.println("1.登录 2.注册");
		int a= arr.nextInt();
			switch(a) {
			case 1:
				enter();
				break;	
			case 2:
				register();
			break;
				}
				
			}
				
				
	

	private static void enter() {
		System.out.println("请输入用户名：");
		String usesrName=arr.next();
		System.out.println("请输入密码：");
		String parkword=arr.next();
		boolean judge=false;
		
		for (int i = 0; i < userinfo.length; i++) {
			if (usesrName.equals(userinfo[i][2]) && parkword.equals(userinfo[i][3])) {
				judge=true;
				break;
			}
		}
		if (judge) {
			System.out.println("登录成功！");
		}else {
			System.out.println("用户名或密码错误！请重新登录！");
			enter();
		}
		
	}
	
	
	private static void register() {
		System.out.println("请输入所属部门：");
		String apartment =arr.next();
		System.out.println("请输入用户角色：");
		String name =arr.next();
		System.out.println("请输入用户名：");
		String user =arr.next();
		System.out.println("请输入密码：");
		String password =arr.next();
		System.out.println("注册成功！");
		System.out.println(user+","+"欢迎来到闽大图书管理系统！");	
		
		int index=-1;
				for (int i = 0; i < userinfo.length; i++) {
					if(userinfo[i][0]==null) {
						index=i;
						break;
					}
				}
				userinfo[index][0]=apartment;
				userinfo[index][1]=name;
				userinfo[index][2]=user;
				userinfo[index][3]=password;
			head();
			}
	
	}

